unit Map_K8;

interface

uses
  SysUtils, Classes, ADODB, DataEngine, Class_K8;

type
  TMap_K8 = class(TDataEngine)
  public
    FDMCD: string;
  public
    function ReadDS(AADODst: TADODataSet): TBaseClass; override;
    function GetStrsIndex(ABaseClass: TBaseClass): string; override;

    function GetStrInsert: string; override;
    function GetStrUpdate: string; override;
    function GetStrDelete: string; override;
    procedure SetParameters(ABaseClass: TBaseClass); override;

    function GetK8(CodeA: string; K8StrsListA: TStringList): TK8;
    function GetTopK8(CodeA: string; K8StrsListA: TStringList): TK8;
  end;

implementation

uses
  StrUtils;

{ TMap_K8 }

function TMap_K8.GetK8(CodeA: string; K8StrsListA: TStringList): TK8;
var
  I: Integer;
begin
  Result := nil;
  if CodeA = '' then Exit;
  for I := 0 to K8StrsListA.Count - 1 do
  begin
    if TK8(K8StrsListA.Objects[I]).KMBM = CodeA then
    begin
      Result := TK8(K8StrsListA.Objects[I]);
      Exit;
    end;
  end;
end;

function TMap_K8.GetStrDelete: string;
begin
  Result := '';
end;

function TMap_K8.GetStrInsert: string;
begin
  Result := '';
end;

function TMap_K8.GetStrsIndex(ABaseClass: TBaseClass): string;
begin
  with TK8(ABaseClass) do
  begin
    Result := '';
  end;
end;

function TMap_K8.GetStrUpdate: string;
begin
  Result := '';
end;

function TMap_K8.GetTopK8(CodeA: string; K8StrsListA: TStringList): TK8;
var
  TopCodeA: string;
begin
  TopCodeA := LeftStr(CodeA, StrToInt(FDMCD[1]));
  Result := GetK8(TopCodeA, K8StrsListA);
end;

function TMap_K8.ReadDS(AADODst: TADODataSet): TBaseClass;
begin
  Result := TK8.Create;
  with TK8(Result) do
  begin
    KMBM := AADODst.FieldByName('KMBM').AsString;
    KMMC := AADODst.FieldByName('KMMC').AsString;
    KMLB := AADODst.FieldByName('KMLB').AsString;
    ZBXS := AADODst.FieldByName('ZBXS').AsString;
    YEFX := AADODst.FieldByName('YEFX').AsString;
    WBZL := AADODst.FieldByName('WBZL').AsString;
    TBKM := AADODst.FieldByName('TBKM').AsString;
    JLDW := AADODst.FieldByName('JLDW').AsString;
    YNXJ := AADODst.FieldByName('YNXJ').AsString;
    USEKH := AADODst.FieldByName('USE_KH').AsString;
    USEBM := AADODst.FieldByName('USE_BM').AsString;
    USEZY := AADODst.FieldByName('USE_ZY').AsString;
    JZXN := AADODst.FieldByName('JZXN').AsString;
    KHGROUP := AADODst.FieldByName('KHGROUP').AsString;
    KMGP := AADODst.FieldByName('KMGP').AsString;
    JC := AADODst.FieldByName('JC').AsString;
    YNNC := AADODst.FieldByName('YNNC').AsString;
    YNNYS := AADODst.FieldByName('YNNYS').AsString;
    YNGQ := AADODst.FieldByName('YNGQ').AsInteger;
  end;
end;

procedure TMap_K8.SetParameters(ABaseClass: TBaseClass);
begin
  inherited;

end;

end.
